/*
 * @Description: 初始化
 * @Autor: HuiSir<273250950@qq.com>
 * @Date: 2024-08-21 21:26:30
 * @LastEditTime: 2024-08-22 00:33:15
 */
(function (window, document) {
  // 开发模式
  window.isDev = location.port !== "" && location.port !== "80";

  // 主题文件路径
  window.themeUriPath = document.querySelector(
    "meta[name=themeUriPath]"
  ).content;

  // 主题颜色初始化
  document.documentElement.setAttribute(
    "data-user-color-scheme",
    window.localStorage.getItem("user-color-scheme") || "light"
  );

  // 滚动跟随
  window.addEventListener("scroll", () => {
    const $navClass = document.getElementById("TopNav")?.classList;
    if (!$navClass) return;
    if (window.scrollY >= 100) {
      $navClass.contains("fixed") || $navClass.add("fixed");
    } else {
      $navClass.contains("fixed") && $navClass.remove("fixed");
    }
  });
})(window, document);
